styleproperty: Add an affects-size property
authorBenjamin Otte <otte@redhat.com>
Fri, 30 Nov 2012 17:57:56 +0000 (18:57 +0100)
committerBenjamin Otte <otte@redhat.com>
Fri, 30 Nov 2012 19:10:23 +0000 (20:10 +0100)
This property will be used to avoid gtk_widget_queue_resize() calls in
favor of gtk_widget_queue_draw().

gtk/gtkcssstyleproperty.c
gtk/gtkcssstylepropertyprivate.h

index 7bb1e688e21a303e54c3b0c533a6bad71f3f8077..9327921d5a46afb76d864951ba6e05296e0026e2 100644 (file)
@@ -38,6 +38,7 @@
 enum {
   PROP_0,
   PROP_ANIMATED,
+  PROP_AFFECTS_SIZE,
   PROP_ID,
   PROP_INHERIT,
   PROP_INITIAL
@@ -70,6 +71,9 @@ gtk_css_style_property_set_property (GObject      *object,
     case PROP_ANIMATED:
       property->animated = g_value_get_boolean (value);
       break;
+    case PROP_AFFECTS_SIZE:
+      property->affects_size = g_value_get_boolean (value);
+      break;
     case PROP_INHERIT:
       property->inherit = g_value_get_boolean (value);
       break;
@@ -96,6 +100,9 @@ gtk_css_style_property_get_property (GObject    *object,
     case PROP_ANIMATED:
       g_value_set_boolean (value, property->animated);
       break;
+    case PROP_AFFECTS_SIZE:
+      g_value_set_boolean (value, property->affects_size);
+      break;
     case PROP_ID:
       g_value_set_boolean (value, property->id);
       break;
@@ -251,6 +258,13 @@ _gtk_css_style_property_class_init (GtkCssStylePropertyClass *klass)
                                                          P_("Set if the value can be animated"),
                                                          FALSE,
                                                          G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (object_class,
+                                   PROP_AFFECTS_SIZE,
+                                   g_param_spec_boolean ("affects-size",
+                                                         P_("Affects size"),
+                                                         P_("Set if the value affects the sizing of elements"),
+                                                         TRUE,
+                                                         G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
   g_object_class_install_property (object_class,
                                    PROP_ID,
                                    g_param_spec_uint ("id",
@@ -381,6 +395,23 @@ _gtk_css_style_property_is_animated (GtkCssStyleProperty *property)
   return property->animated;
 }
 
+/**
+ * _gtk_css_style_property_affects_size:
+ * @property: the property
+ *
+ * Queries if the given @property affects the size of elements. This is
+ * used for optimizations inside GTK, where a gtk_widget_queue_resize()
+ * can be avoided if the property does not affect size.
+ *
+ * Returns: %TRUE if the property affects sizing of elements.
+ **/
+gboolean
+_gtk_css_style_property_affects_size (GtkCssStyleProperty *property)
+{
+  g_return_val_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property), FALSE);
+
+  return property->affects_size;
+}
 /**
  * _gtk_css_style_property_get_id:
  * @property: the property
index b04b2679a98b2d04d9cb4cb85fb0bb0ae4eb10af..34411e06933ccb14cf656ccfb0901224912e0711 100644 (file)
@@ -49,6 +49,7 @@ struct _GtkCssStyleProperty
   guint id;
   guint inherit :1;
   guint animated :1;
+  guint affects_size :1;
 
   GtkCssStylePropertyParseFunc parse_value;
   GtkCssStylePropertyQueryFunc query_value;
@@ -71,6 +72,7 @@ GtkCssStyleProperty *   _gtk_css_style_property_lookup_by_id    (guint
 
 gboolean                _gtk_css_style_property_is_inherit      (GtkCssStyleProperty    *property);
 gboolean                _gtk_css_style_property_is_animated     (GtkCssStyleProperty    *property);
+gboolean                _gtk_css_style_property_affects_size    (GtkCssStyleProperty    *property);
 guint                   _gtk_css_style_property_get_id          (GtkCssStyleProperty    *property);
 GtkCssValue  *          _gtk_css_style_property_get_initial_value
                                                                 (GtkCssStyleProperty    *property);